package com.eamois.ui.util;

import java.awt.Component;

import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;

import com.eamois.po.Group;
import com.eamois.po.Person;
import com.ufidaicon.icons.BrowserUfidaIcons;

public class GroupAndPersonTreeRenderer extends DefaultTreeCellRenderer {

	public GroupAndPersonTreeRenderer() {
	}

	public Component getTreeCellRendererComponent(JTree tree, Object value,
			boolean sel, boolean expanded, boolean leaf, int row,
			boolean hasFocus) {
		super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf,
				row, hasFocus);
		DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
//		if (node.isRoot()) {
//			setIcon(new ImageIcon(
//					com.eamois.icon.GetIcons.class.getResource("engine.png")));
//		} else {
//			if(node.getUserObject().getClass()==Manual.class){
//				setIcon(BrowserUfidaIcons.ICON_FILE_TXTICON);
//			}else{
//				setIcon(new ImageIcon(com.eamois.icon.GetIcons.class.getResource("part.png")));
//			}
//		}
		if(node.getUserObject() instanceof Group){
			setIcon(BrowserUfidaIcons.ICON_USER_USERGROUP);
		}else if(node.getUserObject() instanceof Person){
			setIcon(BrowserUfidaIcons.ICON_USER_USER);
		}
//		if(node.isLeaf()){
//			if(node.getUserObject().getClass()==Technology.class){
//				Technology tech = (Technology)node.getUserObject();
//				if(tech.getEnsipBoms()!=null&&tech.getEnsipBoms().size()!=0){
//					setForeground(Color.BLUE);
//				}
//			}
//		}
		return this;
	}
}
